package com.pet.exchange;

import com.pet.entity.PetInformation;
import com.pet.mapper.UserInformationMapper;
import com.pet.vo.web.PetInformationVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@Slf4j
@Component
public class PetInfoUtil {

    @Autowired
    UserInformationMapper userInformationMapper;

     public PetInformationVO exchangePetInfoUtil(PetInformation e){

         PetInformationVO vo = new PetInformationVO();
         if(e!= null){
             BeanUtils.copyProperties(e,vo);
             //对 接种疫苗情况 是否驱虫情况 是否绝育情况进行判断
             if ( e.getVaccine() == 1){
                 vo.setVaccine("已接种疫苗");
             }else if (e.getVaccine() == 2){
                 vo.setVaccine("未接种疫苗");
             }else {
                 vo.setVaccine("不详");
             }

             if ( e.getInsectRepellent() == 1){
                 vo.setInsectRepellent("已驱虫");
             }else if(e.getInsectRepellent() == 2){
                 vo.setInsectRepellent("未驱虫");
             }else {
                 vo.setInsectRepellent("不详");
             }

             if ( e.getSterilization() == 1){
                 vo.setSterilization("已绝育");
             }else if (e.getSterilization() == 2){
                 vo.setSterilization("未绝育");
             }else {
                 vo.setSterilization("不详");
             }
             vo.setCreateUser(userInformationMapper.selectName(e.getCreateUser()));
         }


        return vo;
    }
}
